package ru.narod.amidoriya.app.sushibaramidoriya;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.google.ads.AdRequest;
import com.google.ads.AdView;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;


import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.ads.*;

public class Aboutorg  extends SherlockActivity{
	ImageView inetorg;
	Button abutton;
	OnClickListener appoclbtn;
	TextView adress2;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.aboutorg);
		inetorg = (ImageView) findViewById(R.id.imageinet);
		abutton = (Button) findViewById(R.id.aboutbutton);
		adress2 = (TextView) findViewById(R.id.textView_adress2);
		inetorg.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				try {	
					String sweb = getString(R.string.web);
					Intent brouzintent = new Intent(Intent.ACTION_VIEW,Uri.parse(sweb));
					startActivity(brouzintent);
				} catch (Exception e) {

				}
			}	
		});

		abutton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {

				try {	
					finish();
				} catch (Exception e) {

				}
			}	
		});
		adress2.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				try {					
					Uri geo = Uri.parse("geo:0,0?q="+getString(R.string.adres));
					Intent geoMap = new Intent(Intent.ACTION_VIEW, geo);
					startActivity(geoMap);					
				} catch (Exception e) {

				}

			}	
		});

		



	}
	
	


	public boolean onCreateOptionsMenu(Menu menu) { 

		getSupportMenuInflater().inflate(R.menu.pmenu, menu);

		return true;
	}

	@Override
	public boolean onPrepareOptionsMenu(Menu menu) { 

		menu.findItem(R.id.loaditem1).setEnabled(true);
		menu.findItem(R.id.pitem2).setEnabled(true);
		menu.findItem(R.id.abitem3).setEnabled(true);

		return super.onPrepareOptionsMenu(menu);
	}

	@Override
	public boolean  onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()) { 
		
		case android.R.id.home:
			finish();			
			break;
		case R.id.loaditem1:
			GoMain();
			break; 
		case R.id.pitem2:
			//���������
			try {
				Intent Preferintent = new Intent(getApplicationContext(),PreferAmidoriya.class);
				startActivityForResult(Preferintent,0);
			} catch (Exception e) {

			}
			break; 
		case R.id.abitem3: 
			//� ���������
			try {
				Intent intentapp = new Intent(getApplicationContext(), Aboutapp.class);
				startActivityForResult(intentapp,0);
			} catch (Exception e) {

			}
			break;
		}       


		return super.onOptionsItemSelected(item); 

	} 
	private void GoMain() {
		AlertDialog.Builder buildergomain = new AlertDialog.Builder(this);
		buildergomain.setTitle(R.string.lt_app);		
		buildergomain.setMessage(R.string.lmmm_app);		
		buildergomain.setNegativeButton(R.string.qn_app, null);
		buildergomain.setPositiveButton(R.string.qy_app, new OnClickListener() {
			public void onClick(DialogInterface arg0, int arg1) {
				setResult(7);
				finish(); 	            	

			}
		}).create().show();	
	}
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);

		if (resultCode == 7) {
			setResult(7);
			finish();
		}
		//����� ��� �� �������� �������� � � ���������
		if (resultCode ==  5) {
			try {
				openOptionsMenu();
			} catch (Exception e) {

			}
		}
		if (resultCode ==  9) {
			try {
				Intent Preferintent = new Intent(getApplicationContext(),PreferAmidoriya.class);
				startActivityForResult(Preferintent,0);
			} catch (Exception e) {

			}
		}
		if (resultCode ==  10) {
			try {
				Intent intentapp = new Intent(getApplicationContext(), Aboutapp.class);
				startActivityForResult(intentapp,0);
			} catch (Exception e) {

			}
		}

	}


}
